﻿using System;
using System.Collections.Generic;
using System.Text;
using LBoL.Base;
using LBoL.ConfigData;
using LBoL.Core.Battle.BattleActions;
using LBoL.Core.Battle;
using LBoL.Core.Cards;
using ProbeMod.Cards.Template;
using LBoLEntitySideloader.Attributes;

namespace ProbeMod.Cards
{
    public sealed class ProbeMineralsDef : ProbeCardTemplate
    {
        public override CardConfig MakeConfig()
        {
            var config = GetCardDefaultConfig();

            config.Rarity = Rarity.Common;
            config.Type = CardType.Skill;
            config.TargetType = TargetType.Nobody;
            config.Colors = new List<ManaColor>() { ManaColor.Blue };

            config.Cost = ManaGroup.Empty;
            config.UpgradedCost = ManaGroup.Empty;

            config.Keywords = Keyword.Forbidden;
            config.UpgradedKeywords = Keyword.Forbidden;

            config.Value1 = 5;  //  金币产生量
            config.Value2 = 3; //  金币生产次数

            config.Index = CardIndexGenerator.GetUniqueIndex(config);

            return config;
        }
    }

    /// <summary>
    /// 晶体矿
    /// 
    /// 弃掉此牌时，获得8/15金（剩余3次）
    /// </summary>
    [EntityLogic(typeof(ProbeMineralsDef))]
    public sealed class ProbeMinerals : ProbeCard
    {
        public int Money { get => IsUpgraded ? Value1+5 : Value1; }

        public int Count = 3;

        protected override void OnEnterBattle(BattleController battle)
        {
            Count = Value2;
        }

        public override IEnumerable<BattleAction> OnDiscard(CardZone srcZone)
        {
            if(Count > 0)
            {
                yield return new GainMoneyAction(Money);
                Count--;
            }

        }
    }
}
